package com.sh.weblogspringboot.common.config;

import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Mybatis配置类.
 *
 * @author songHai
 * @Classname MybatisPlusConfig
 * @Description
 * @Date 2025/3/25 23:04
 */
@Configuration
@MapperScan("com.sh.weblogspringboot.common.domain.mapper")
public class MybatisPlusConfig {

    /**
     * 分页插件.
     *
     * @return
     */
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor());
        return interceptor;
    }

    /**
     * 自定义批量插件 SQL注入器.
     *
     * @return
     */
    @Bean
    public InsertBatchSqlInjector insertBatchSqlInjector() {
        return new InsertBatchSqlInjector();
    }
}
